using System;
using System.ComponentModel;

namespace IValidate
{
	public class ValidateMinLengthAttribute : ModelValidatorBaseImpl
	{
		public int MinLength { get; private set; }
		public ValidateMinLengthAttribute(int minLength, string errorMessage, bool required)
			: base(errorMessage, required)
		{
			MinLength = minLength;
		}

		public override bool Validate(object value)
		{
			if (value == null) return false;
			if (System.Convert.ToString(value).Length < this.MinLength) return false;
			return true;
		}
	}
}
